package com.sunsharing.flow.exe;

import com.sunsharing.common.Context;
import com.sunsharing.flow.model.Node;
import com.sunsharing.flow.model.Transition;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: criss
 * Date: 13-5-4
 * Time: 下午5:30
 * To change this template use File | Settings | File Templates.
 */
public class ExecutionContext {

    /**执行节点位置**/
    public static final String EXECUTED_NODE_POSITION = "EXECUTED_NODE_POSITION";

    /**该执行上下文下的节点**/
    protected Node node = null;



    /**该执行上下文下的迁移**/
    protected Transition transition;

    /**子流程实例**/
    //protected ProcessInstance subProcessInstance;


    /**令牌**/
    protected Token token;

    static ThreadLocal<ExecutionContext> contextThreadLocal = new ThreadLocal<ExecutionContext>();

    public static ExecutionContext getExcutionContext()
    {
        return contextThreadLocal.get();
    }
    public static void setExcutionContext(ExecutionContext context)
    {
        contextThreadLocal.set(context);
    }
    public static void removeExcutionContext()
    {
        contextThreadLocal.remove();
    }

    public ExecutionContext(Token token) {
        this.token = token;
    }

    public Node getNode() {
        return node;
    }

    public void setNode(Node node) {
        this.node = node;
    }

    public Transition getTransition() {
        return transition;
    }

    public void setTransition(Transition transition) {
        this.transition = transition;
    }

    public Token getToken() {
        return token;
    }

    public void setToken(Token token) {
        this.token = token;
    }

    public Context getContext() {
        return getToken().getContext();
    }

    public void setContext(Context context) {
        this.getToken().setContext(context);
    }
}
